package com.wc5818.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.wc5818.entity.User;
import com.wc5818.service.UserService;

/**
 * @Author:yqb
 * @Date: 2020/01/09
 * @Time: 15:20
 */

@RestController
@RequestMapping("/adm/api")
public class UserController {

	@Autowired
	private UserService userService;

	@RequestMapping("getAllUser")
	public List<User> getAllUser() {
		List<User> list = userService.findAllUser();

		System.out.println(list);
		return list;
	}

	@RequestMapping(value = "/addUser", method = RequestMethod.GET)
	public void addUser(@RequestParam("userName") String userName,
			@RequestParam(value = "passWord", defaultValue = "0") String passWord) {
		User user = new User();
		user.setUserName(userName);
		user.setPassWord(passWord);

		userService.insert(user);
	}

}
